/////////////////////////////////////////////////////
// File Name: mac_t_v1_tb.v
// Author: zeping fan
// mail:   zpfan007@163.com
// Created Time: 2023年06月12日 星期一 11时08分20秒
/////////////////////////////////////////////////////

module mac_t_v1_tb();

reg             clk;
reg             rst_n;
reg             tx_clk;
wire            tx_dv;
wire            tx_d;
wire            qm_dfifo_rd;
reg     [7:0]   qm_dfifo_dout;
wire            qm_pfifo_rd;
reg     [15:0]  qm_pfifo_dout;
reg             qm_pfifo_empty;

wire    [70*8-1:0] mem;

assign  mem = 'h0123456789abcdef_fedcba9876543210_0123456789abcdef_fedcba9876543210_0123456789abcdef_fedcba9876543210_0123456789abcdef_fedcba9876543210_0123456789ab;

always #5   clk = ~clk;
always #20  tx_clk = ~tx_clk;

initial begin
    $fsdbDumpfile("mac_t.fsdb");
    $fsdbDumpvars(0,mac_t_v1_tb);
    $fsdbDumpMDA();

    clk = 1'b0;
    rst_n = 1'b0;
    tx_clk = 1'b0;
    qm_pfifo_empty = 1'b1;
    qm_dfifo_dout[7:0] = 8'b0;
    qm_pfifo_dout[15:0] = 16'b0;
    repeat(2) @(posedge clk);#0;
    rst_n = 1'b1;
    repeat(2) @(posedge clk);#0;
    qm_pfifo_empty = 1'b0;
    repeat(2)@(posedge clk);#0;
    qm_pfifo_dout[15:0] = 16'h0028;
    repeat(7)@(posedge clk);#0;
    for(integer i=40;i>0;i=i-1)begin
        qm_dfifo_dout[7:0] = mem[i*8-1-:8];
        @(posedge clk);#0;
    end
    qm_pfifo_empty =1'b1;


    #8000;
    $finish;

end


mac_t_v1
x_mac_t(
    .clk(clk),
    .rst_n(rst_n),
    .tx_clk(tx_clk),
    .tx_dv(tx_dv),
    .tx_d(tx_d),
    .qm_dfifo_rd(qm_dfifo_rd),
    .qm_dfifo_dout(qm_dfifo_dout),
    .qm_pfifo_rd(qm_pfifo_rd),
    .qm_pfifo_dout(qm_pfifo_dout),
    .qm_pfifo_empty(qm_pfifo_empty)
);

endmodule
